package com.tencent.controller;


import com.tencent.service.LoginService;
import com.tencent.service.RistService;
import com.tencent.utils.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.xml.crypto.Data;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import static com.tencent.utils.IdUtil.tl;

@RestController
@RequestMapping("/risk")
public class RiskController {

    @Autowired
    private RistService service;

    @Autowired
    private LoginService loginService;



    @PostMapping("/risk1")
    public void risk1 (String gender){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Object username = authentication.getPrincipal();
        String s = username.toString();
        Integer id = loginService.findIdByUsername(s);
        service.rist1(gender,id);
    }

    @PostMapping("/risk2")
    public void risk2( String gender){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Object username = authentication.getPrincipal();
        String s = username.toString();
        Integer id = loginService.findIdByUsername(s);
        service.rist2(gender,id);
    }

    @PostMapping("/risk3")
    public void risk3( String gender){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Object username = authentication.getPrincipal();
        String s = username.toString();
        Integer id = loginService.findIdByUsername(s);
        service.rist3(gender,id);
    }

}
